﻿using System;
using System.Collections.Generic;

namespace Gonte.Workflow
{
    /// <summary>
    /// The task result for simple tasks
    /// </summary>
    public class TaskResult
        : IComparable
    {
        #region IComparable Members

        public int CompareTo(object taskResult)
        {
            ExceptionThrower.ThrowWhenNull("Value", _value);
            ExceptionThrower.ThrowWhenNull("taskResult", taskResult);
            ExceptionThrower.ThrowWhenNot
                (taskResult is TaskResult,
                "The parameter passed to TaskResult.CompareTo must be a TaskResult type");

            TaskResult result = (TaskResult)taskResult;

            return _value.ToString().CompareTo(result.Value);
        }

        #endregion

        #region Properties

        /// <summary>
        /// The main value to be returned by the task
        /// </summary>
        public object Value
        {
            get { return _value; }
            set { _value = value; }
        }

        /// <summary>
        /// Additional values that are returned by the task that are not used in the comparison method
        /// </summary>
        public Dictionary<string, object> AditionalValues
        {
            get { return _aditionalValues; }
            set { _aditionalValues = value; }
        } 

        #endregion

        #region Fields

        private object _value;
        private Dictionary<string, object> _aditionalValues;

        #endregion
    }
}
